package values.common
{
import mx.utils.StringUtil;
import core.Configuration;

public class IconValue
{
    private static const XML_PATTERN:String = "<icon key=\"{0}\" url=\"{1}\" />";
    
    [Data(type="field", mapping="@key")]
    public var key:String;
    
    [Data(type="field", mapping="@url")]
    public var baseUrl:String;
    
    public function get url():String
    {
        return Configuration.assetsPath + baseUrl;
    }
    
    public function clone():IconValue
    {
        var vo:IconValue = new IconValue();
        vo.key = key;
        vo.baseUrl = baseUrl;
        return vo;
    }
    
    public function generateXML():XML
    {
        var xmlStr:String = StringUtil.substitute(XML_PATTERN, 
                                                                        this.key,
                                                                        this.baseUrl);
        return new XML(xmlStr);
    }
}
}